﻿using System;
using System.Web.UI.WebControls;
using BIS.Portal.Core.Base;
using BIS.Portal.Core.Global;
using System.Collections.Generic;
using BIS.Portal.Modules.CMS.BO;
using BIS.Portal.Modules.CMS.Entity;


namespace BIS.Portal.Modules.CMS
{
    public partial class CmsArticleByHotNewDisplayTypeControl_Settings : ControlSettingBase
    {
        #region Lấy dữ liệu settings
        private string NoiDungHienThi
        {
            get { return GetControlSetting<string>(ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLNoiDungHienthi, PortalContext.LanguageAlias); }
        }
        private bool HienThiTinNoiBatB
        {
            get { return GetControlSetting<bool>(ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLTinNoiBatHot, PortalContext.LanguageAlias); }
        }
        private bool HienThiAnhMinhHoaTinNoiBat
        {
            get { return GetControlSetting<bool>(ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLAnhMinhHoaHot, PortalContext.LanguageAlias); }
        }
        private bool HienThiMotaTinNoiBat
        {
            get { return GetControlSetting<bool>(ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLMieuTaHot, PortalContext.LanguageAlias); }
        }
        private bool HienThiLinkCtTinNoiBat
        {
            get { return GetControlSetting<bool>(ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLHienThiLinkHot, PortalContext.LanguageAlias); }
        }
        private bool HienThiTinMoiB
        {
            get { return GetControlSetting<bool>(ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLTinMoi, PortalContext.LanguageAlias); }
        }
        private bool HienThiAnhMinhHoaTinMoiB
        {
            get { return GetControlSetting<bool>(ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLAnhMinhHoaTinMoi, PortalContext.LanguageAlias); }
        }
        private bool HienThiMotaTinMoiB
        {
            get { return GetControlSetting<bool>(ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLHienThiMotaTinMoi, PortalContext.LanguageAlias); }
        }
        private bool HienThiLinkCtTinMoiB
        {
            get { return GetControlSetting<bool>(ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLHienThiLinkTinMoi, PortalContext.LanguageAlias); }
        }
        private int SoLuongHienThiTinNoiBat
        {
            get { return GetControlSetting<int>(ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLSoLuongTinHot, PortalContext.LanguageAlias); }
        }
        private int SoLuongHienThiTinMoi
        {
            get { return GetControlSetting<int>(ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLSoluongTinMoi, PortalContext.LanguageAlias); }
        }
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadData();
        }


        private void LoadData()
        {
            IList<ClientCmsArticleSpecicalDisplayAnDisplayEnity> list = ClientCmsArticleSpecicalDisplayAnDisplayBO.GetDisplayTypeName();
            ddlLoaiNoiDung.Items.Clear();
            for (int i = 0; i < list.Count; i++)
            {
                ListItem item = new ListItem(list[i].Display_type_name, list[i].Display_type_id.ToString());
                ddlLoaiNoiDung.Items.Add(item);
            }

            //Binđ data controls setting

            if (!string.IsNullOrEmpty(NoiDungHienThi))
                ddlLoaiNoiDung.SelectedValue = NoiDungHienThi;
            ddlTinNoiBat.SelectedIndex = HienThiTinNoiBatB ? 0 : 1;
            txtSlTinNoiBat.Text = Convert.ToString(SoLuongHienThiTinNoiBat);
            ddlAnhMinhHoaTinNoiBat.SelectedIndex = HienThiAnhMinhHoaTinNoiBat ? 0 : 1;
            ddlMoTaTinNoiBat.SelectedIndex = HienThiMotaTinNoiBat ? 0 : 1;
            ddlLinkXemCTTinNoiBat.SelectedIndex = HienThiLinkCtTinNoiBat ? 0 : 1;
            ddlHienThiTinMoi.SelectedIndex = HienThiTinMoiB ? 0 : 1;
            txtSlTinMoi.Text = Convert.ToString(SoLuongHienThiTinMoi);
            ddlMoTaTinMoi.SelectedIndex = HienThiMotaTinMoiB ? 0 : 1;
            ddlAnhMinhHoaTinMoi.SelectedIndex = HienThiAnhMinhHoaTinMoiB ? 0 : 1;
            ddlLinkCTTinMoi.SelectedIndex = HienThiLinkCtTinMoiB ? 0 : 1;

        }
        public override void SaveSettings(Dictionary<string, string> settings)
        {

            SetControlSettingForAllLanguages(ddlLoaiNoiDung.ID, ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLNoiDungHienthi, settings);
            SetControlSettingForAllLanguages(ddlTinNoiBat.ID, ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLTinNoiBatHot, settings);
            SetControlSettingForAllLanguages(txtSlTinNoiBat.ID, ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLSoLuongTinHot, settings);
            SetControlSettingForAllLanguages(ddlAnhMinhHoaTinNoiBat.ID, ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLAnhMinhHoaHot, settings);
            SetControlSettingForAllLanguages(ddlMoTaTinNoiBat.ID, ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLMieuTaHot, settings);
            SetControlSettingForAllLanguages(ddlLinkXemCTTinNoiBat.ID, ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLHienThiLinkHot, settings);
            SetControlSettingForAllLanguages(ddlHienThiTinMoi.ID, ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLTinMoi, settings);
            SetControlSettingForAllLanguages(txtSlTinMoi.ID, ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLSoluongTinMoi, settings);
            SetControlSettingForAllLanguages(ddlMoTaTinMoi.ID, ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLHienThiMotaTinMoi, settings);
            SetControlSettingForAllLanguages(ddlAnhMinhHoaTinMoi.ID, ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLAnhMinhHoaTinMoi, settings);
            SetControlSettingForAllLanguages(ddlLinkCTTinMoi.ID, ModuleSettingNames.CmsArticleByHotNewDisplayType.DDLHienThiLinkTinMoi, settings);

        }

    }
}